package org.fin.homeworkspringboot.service.impl;

import org.fin.homeworkspringboot.pojo.Article;
import org.fin.homeworkspringboot.repository.ArticleRepository;
import org.fin.homeworkspringboot.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class ArticleServiceImpl implements ArticleService {

  private final ArticleRepository articleRepository;

  @Autowired
  public ArticleServiceImpl(ArticleRepository articleRepository) {
    this.articleRepository = articleRepository;
  }

  @Cacheable("article")
  @Override
  public Page<Article> findAllByPage(Pageable pageable) {
    return articleRepository.findAll(pageable);
  }
}
